package com.yy.tech.data.coder.secret.std;

import com.yy.tech.data.coder.secret.decrypt.Decrypt;
import com.yy.tech.data.coder.secret.encrypt.Encrypt;
import com.yy.tech.data.coder.secret.utils.Base64Encryptor;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * @author yy
 * @date 2022/4/4
 * @description: TODO
 */
@Component
public class Base64Secret implements Encrypt, Decrypt {

    @Override
    public String decrypt(final String target) {
        if (StringUtils.isEmpty(target)){
            return target;
        }
        return Base64Encryptor.decrypt(target);
    }

    @Override
    public String encrypt(final String source) {
        if (StringUtils.isEmpty(source)){
            return source;
        }
        return Base64Encryptor.encrypt(source);
    }
}
